<?php
require_once '../libs/app.config.php';
session_start();
if($_SESSION['LoginId'] == false){
	header("Location:login.php");
}
//单项删除
if($_POST['delid'])
{
  $sql="delete from admin_group where id='".$_POST['delid']."'";
  $query=$tpm->query($sql);
  if($query>0)
  echo "1";
  else
  echo "0";
}
//分类列表
$sql="select * from admin_group";
$query=$tpm->query($sql);
while($rows=$tpm->fetch_array($query))
{

$group_list[]=array('id'=>$rows['id'],
				  'group_name'=>$rows['group_name']
				 );
}

if($_POST['submit'])
{
	$add=array("group_name"=>$_POST['group_name']);
	$insert=$tpm->insert("admin_group",$add);
	if($insert>0)
	echo "<script>alert('添加成功');history.back();</script>";
}



require_once(INCLUDE_PATH.'template.inc.php');  //模板类及对象$tpl的加载
$tpl->assign("group_list",$group_list);
$tpl->display("admin_group.html");
?>